<template>
  <div>
    <mt-header title="登录">
      <router-link to="/" slot="left">
        <mt-button icon="back">返回</mt-button>
      </router-link>
    </mt-header>
    <div style="padding: 15px">
      <mt-field label="用户名" placeholder="请输入用户名" v-model="username"></mt-field>
      <mt-field label="密码" placeholder="请输入密码" type="password" v-model="password"></mt-field>
      <mt-button size="large" type="primary" @click.native="handleLogin">登录</mt-button>
      <p style="text-align: center; color: #999">
        testB 可以查看个人个人业绩/团队业绩/培训奖励
        <br>
        testC 可以查看个人个人业绩/团队业绩
      </p>
    </div>
  </div>
</template>

<script>
export default {
  name: 'login',
  metaInfo: {
    title: '登录'
  },
  data () {
    return {
      username: 'testB',
      password: 'test'
    }
  },
  methods: {
    handleLogin () {
      console.log('login')
      this.$store.dispatch('main/LoginByUsername',
        { username: this.username, password: this.password }
      ).then(() => {
        this.loading = false
        this.$router.push({ path: '/' })
      }).catch(() => {
        this.loading = false
      })
    }
  }
}
</script>

<style scoped>

</style>
